package com.coocaa.ops.common.tool.integer;

/**
 * @author bijiahao
 * @date : 2019/7/16.
 * @description
 *     整型数据 工具类
 *
 */
public class IntegerUtil {
    public static Integer getInt(Object value, Integer defaultValue) {
        Integer intValue = getInt(value);
        return intValue == null ? defaultValue : intValue;
    }

    public static Integer getInt(Object value) {
        if (null == value) {
            return null;
        }
        return Integer.parseInt(value.toString());
    }

    public static Integer parseInt(Object value, int defaultValue) {
        if (null == value) {
            return defaultValue;
        } else {
            try {
                return Integer.parseInt(value.toString());
            } catch (NumberFormatException var3) {
                return defaultValue;
            }
        }
    }
}
